home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #2 / Monster Media No. 2 (Monster Media)(1994).ISO / prog_pas / ddplus63.zip / EDITTEST.PAS < prev    next >
Pascal/Delphi Source File  |  1991-09-20  |  6KB  |  165 lines

  1. {--------------------------------------------------------------------------}
  2. {                                                                          }
  3. { Program: EDITTEST                                                        }
  4. {                                                                          }
  5. { Purpose: Test the CFGEDITOR unit and demonstrate how procedures can be   }
  6. {          "hooked" into an alt-key.                                       }
  7. {                                                                          }
  8. {--------------------------------------------------------------------------}
  9.  
  10.  
  11. {$V-}
  12. uses doordriv, {We got to use the doordriver unit!}
  13.  
  14.      cfgeditr, {Use CFGEDITR to provide our editor procedures}
  15.  
  16.      crt,      {Why not? We always need CRT for something!}
  17.  
  18.      ddscott;  {Miscellanious procedures that I use}
  19.  
  20.  
  21. var
  22.  name,alias,secret_word,quest,alive,weapon,armour,shield:string;
  23.  money,hits:word;
  24.  
  25.             { ^^^^^ The data for our sample player }
  26.  
  27.  
  28. {$F+}           { <---- Important, we turned on FAR calls because ALTKEYS }
  29.                 { needs them to be "hooked" in properly                   }
  30.  
  31. procedure SampleEditor;
  32. const
  33.  UserEditScreen: templatedef =
  34.                   (Header: 'Demo of the Configurable Editor';
  35.                    Headercolor: green;
  36.                    Titles: (('Name','Alias','Secret Word',
  37.                              'Hits','Money','Quest',
  38.                              '','','',
  39.                              '','','',
  40.                              '','','',
  41.                              '','','',
  42.                              '',''),
  43.                             ('Alive','Weapon','Armour',
  44.                              'Shield','','',
  45.                              '','','',
  46.                              '','','',
  47.                              '', '','','','','','',''));
  48.                    DataLength: ((27,27,27,254,254,55,0,0,0,0,0,0,0,0,0,0,0,0,0,0),
  49.                                 (1,15,15,15,15,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0));
  50.                    Data: (('','','','','','','','','','','','','','','','','','','',''),
  51.                           ('','','','','','','','','','','','','','','','','','','',''));
  52.                    Databyte:    ((0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),
  53.                                  (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0));
  54.                    Dataint:     ((0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),
  55.                                  (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0));
  56.                    Datalongint: ((0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),
  57.                                  (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0));
  58.                    Dataword:    ((0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),
  59.                                  (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0));
  60.                    Startx: 1;
  61.                    Starty: 3;
  62.                    Normalfore: 4; Inversefore: 15; Inverseback: 2; Titlefore: cyan);
  63.  
  64. procedure dataToTemplate(var template: templatedef);
  65. begin;
  66.  with Template do begin;                  {This is where you transfer     }
  67.   data[1,1]:=name;                        {the users data to the template.}
  68.   data[1,2]:=alias;
  69.   data[1,3]:=secret_word;
  70.   dataword[1,4]:=hits;
  71.   dataword[1,5]:=money;
  72.   data[1,6]:=quest;
  73.   data[2,1]:=alive;
  74.   data[2,2]:=weapon;
  75.   data[2,3]:=armour;
  76.   data[2,4]:=shield;
  77.  end;
  78. end;
  79.  
  80. procedure TemplateToData(var template: templatedef);
  81. begin;
  82.  with Template do begin;                  {This is where you transfer    }
  83.   name:=data[1,1];                        {New, and changed data from the}
  84.   alias:=data[1,2];                       {Template to the user data     }
  85.   secret_Word:=data[1,3];
  86.   hits:=dataword[1,4];
  87.   money:=dataword[1,5];
  88.   quest:=data[1,6];
  89.   alive:=data[2,1];
  90.   weapon:=data[2,2];
  91.   armour:=data[2,3];
  92.   shield:=data[2,4];
  93.  end;
  94. end;
  95.  
  96. var
  97.  s,s2: string;
  98.  a,b: integer;
  99.  moresave: boolean;
  100.  blah: word;
  101.  chainout: char;
  102. begin;
  103.  repeat;
  104.   DataToTemplate(UserEditScreen);              {Transfering data to template}
  105.  
  106.  
  107.   DoEntry(UserEditScreen,chainout);      {Allows you to modify the current}
  108.                                          {Data in the template}
  109.  
  110.   TemplateTodata(UserEditScreen);        {Transfering template to data}
  111.  until (chainout=#45);                   {Repeat until ALT-X is encountered}
  112. end;
  113. {$F-}                                    {Far Call is now being turned off}
  114.  
  115. procedure MakeSampleData;                {Things would be kind of boring   }
  116. begin;                                   {without our sample user          }
  117.  name:='Derrick Parkhurst';
  118.  alias:='Sir Lancalot';
  119.  secret_word:='BRAVE';
  120.  Hits:=150;
  121.  money:=1000;
  122.  quest:='To Find The Holy Grail';
  123.  Alive:='Y';
  124.  weapon:='Excalibor';
  125.  armour:='Enchanted Mail';
  126.  shield:='Enchanted Shield';
  127. end;
  128.  
  129. var
  130.  s : string;
  131. begin;
  132.  INITDOORDRIVER('doordriv.ctl');          {DoorDriver must be initialized  }
  133.  
  134.  
  135.  ALTKEYS['E']:=@SampleEditor;             {Here is where we "hook in" the  }
  136.                                           {editor procedure. Remember, we  }
  137.                                           {had to declare it far.          }
  138.  
  139.  New(ALTHELP['E']);                       {create a help record for ALT-E  }
  140.  
  141.  ALTHELP['E']^:='Sample Editor';          {Put some text in our help record}
  142.  
  143.  MakeSampleData;                          {create a sample used.           }
  144.  
  145.  swriteln('Right now, assume this program is a normal door. The following');
  146.  swriteln('prompt would represent the normal main menu of your door. Pressing');
  147.  swriteln('ALT-E (on the sysop side only) will pop up the configurable editor');
  148.  swriteln('for this door. (again, on the sysop side only). The user will be');
  149.  swriteln('paused while the sysop is editing');
  150.  repeat;
  151.   set_foreground(green);
  152.   swriteln('');
  153.   swrite('Command (?=Help,Q=Quit) ? ');
  154.   set_foreground(white);
  155.   sread(s);
  156.   set_foreground(default_fore);
  157.   s:=stu(s);
  158.   if s='?' then begin;
  159.    set_foreground(cyan);
  160.    swriteln('Since this is a test only, we have no help!');
  161.    swriteln('just press ALT-E to bring up the sysop side configurable editor');
  162.    set_foreground(default_fore);
  163.   end;
  164.  until s='Q';
  165. end.